import 'package:flutter/material.dart';

import '../../api/DeviceApi.dart';
import '../../commponets/ItemView.dart';
import '../../home/AppLocale.dart';
import '../../tools/widgets/my_app_bar.dart';
import '../../utils/toast_utils.dart';
import 'model/Device.dart';


class DeviceVersionPage extends StatefulWidget {
  const DeviceVersionPage({
    super.key,
    this.deviceId,
    this.device,
  });

  final int? deviceId;
  final Device? device;

  @override
  State<DeviceVersionPage> createState() => _DeviceVersionPageState();
}

class _DeviceVersionPageState extends State<DeviceVersionPage> {
  final DeviceApi _deviceApi = DeviceApi();
  late int _deviceId;
  Device? _device;

  @override
  void initState() {
    super.initState();

    _deviceId = widget.deviceId!;
    _device = widget.device!;
    // _fetchData();
  }


  // Future<void> _fetchData() async {
  //   try {
  //     final response = await _deviceApi.getDeviceInfo(_deviceId);
  //     if (response.code == 200) {
  //       setState(() {
  //         _device = Device.fromJson(response.data);
  //       });
  //     } else {
  //       AppLocale.text('s_500');
  //     }
  //   } catch (e) {
  //     AppLocale.text('s_get500');;
  //   }
  // }


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: MyAppBar(
        centerTitle: AppLocale.text('d_banbenxinxi'),
        backgroundColor: Colors.transparent,
        dropdownWidth: 140,
        dropdownBackgroundColor: Colors.white,
        dropdownBorderRadius: 20,
      ),


      body: Container(
        child: Column(
          children: [

            const SizedBox(height: 20,),


            ItemView(
              width: 400,
              height: 50,
              leftPadding: 10,
              rightPadding: 20,
              leftWidget: Row(
                children: [
                  const SizedBox(width: 10),
                  Text(
                    AppLocale.text('d_banbenxinxi'),
                    style: TextStyle(
                        fontSize: 15.0,
                        color: Colors.black
                    ),
                  ),
                ],
              ),
              rightWidget: Row(
                children: [
                  Text(
                    _device?.version ?? '',
                    style: TextStyle(
                        fontSize: 14.0,
                        color: Colors.black54
                    ),
                  ),
                ],
              ),
              borderRadius: 8,
              onTap: () {

              },
            ),


            ItemView(
              width: 400,
              height: 50,
              leftPadding: 10,
              rightPadding: 20,
              leftWidget: Row(
                children: [
                  const SizedBox(width: 10),
                  Text(
                    AppLocale.text('d_jianchagengxin'),
                    style: TextStyle(
                        fontSize: 15.0,
                        color: Colors.black
                    ),
                  ),
                ],
              ),
              rightWidget: Row(
                children: [
                  Text(
                    AppLocale.text('d_yishizuixinbanben'),
                    style: TextStyle(
                        fontSize: 14.0,
                        color: Colors.black54
                    ),
                  ),
                ],
              ),
              borderRadius: 8,
              onTap: () {
              },
            ),






          ],
        )
      ),
    );
  }

}



























